comm: unexpected "file is not in sorted order"#12280
Open
blixygetir wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts comm’s sorted-order error reporting to match GNU behavior more closely, emitting file-level warnings only in explicit --check-order mode and deferring default-mode reporting to the end.
Changes:
- Gate file-level “file N is not in sorted order” warnings behind
--check-order. - Ensure out-of-order detection still records an error in default mode, even when warnings aren’t printed immediately.
- Update end-of-run error reporting to conditionally emit file-level and general “input is not in sorted order” messages.
Comments suppressed due to low confidence (1)
src/uu/comm/src/comm.rs:332
- These file-level error messages are hardcoded English strings, which bypasses the existing localization key (
comm-error-file-not-sorted) used elsewhere and will regress non-English locales. Use the translation key with the appropriatefile_numinstead of embedding the full message text here.
let _ = writeln!(stderr(), "comm: file 1 is not in sorted order");
}
if checker2.has_error {
let _ = writeln!(stderr(), "comm: file 2 is not in sorted order");
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -315,8 +321,15 @@ fn comm( | |||
| .map_err_context(|| translate!("comm-error-write"))?; | |||
|
|
|||
| if should_check_order && (checker1.has_error || checker2.has_error) { | |||
Comment on lines
+116
to
+127
| // Print file-level warnings only if --check-order was explicitly passed | ||
| // (in default mode, these are printed later in the final error reporting) | ||
| if !is_ordered && !self.has_error && self.check_order { | ||
| let _ = writeln!( | ||
| stderr(), | ||
| "{}", | ||
| translate!("comm-error-file-not-sorted", "file_num" => self.file_num.as_str()) | ||
| ); | ||
| } | ||
|
|
||
| // Always mark that we have an error, regardless of check_order flag | ||
| if !is_ordered && !self.has_error { |
|
GNU testsuite comparison: |
Comment on lines
+328
to
+331
| let _ = writeln!(stderr(), "comm: file 1 is not in sorted order"); | ||
| } | ||
| if checker2.has_error { | ||
| let _ = writeln!(stderr(), "comm: file 2 is not in sorted order"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #12253
The output matches the GNU suite, displaying the error message conditionally on the basis of the checking mode.
I have made changes to the error detection and displaying logic, handles all the test cases as per GNU.